﻿using ALEXBlog.Entity;
using ALEXBlog.Entity.ViewModel;
using ALEXBlog.IRepository.Base;
using ALEXBlog.IService;
using ALEXBlog.Service.Base;
using AutoMapper;
using System.Threading.Tasks;

namespace ALEXBlog.Service
{

    public class UsersService : BaseService<UsersModel>, IUsersService
    {
        public IMapper mapperContext;
        public UsersService(IBaseRepository repository, IMapper mapper) : base(repository)
        {
            mapperContext = mapper;
        }

        public async Task<int> UpdateAsync(UsersVM userVM)
        {
            return await repositoryContext.UpdateAsync(mapperContext.Map<UsersModel>(userVM));
        }

        public async Task<int> UpdateAsync(params UsersVM[] models)
        {
            return await repositoryContext.UpdateAsync(mapperContext.Map<UsersModel[]>(models));
        }
    }
}
